package com.cmcc.pcap.packet.sctp.ngaps;

import com.cmcc.pcap.packet.sctp.SctpConnection;
import com.cmcc.pcap.packet.sctp.SctpPacketDecorator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.pcap4j.packet.namednumber.SctpChunkType;

import java.util.HashSet;
import java.util.Set;

public class NgapMessagesFilter {

    public static Logger logger = LogManager.getLogger(NgapMessagesFilter.class);

    public static NgapMessages filter(SctpConnection sctpConnection) {

        NgapMessages ngmessages = new NgapMessages(sctpConnection);
        for(SctpPacketDecorator spd:sctpConnection.retransmissionDataMergeAl){
            if(spd.chunktypelist.contains(SctpChunkType.DATA)){
                ngmessages.al_filtered.add(spd);
            }
        }

        Set<String> single = new HashSet<>();
        ngmessages.al_filtered.forEach(t->{
            t.chunktypelist.forEach(p->{
                single.add(p.valueAsString());
            });
        });
        return ngmessages;
    }
}
